"""
git for-each-ref --sort='-committerdate' \
                   --format="%(refname:short)%09%(committerdate)" \
                   refs/heads
"""

import datetime as dt
import time


def cls():
    for i in range(30):
        print()


s = 'Sat Sep 24 22:08:51 2022 +0800'
# t = time.strptime(s, "%a %b %d %H:%M:%S %Y %z")
t = dt.datetime.strptime(s, "%a %b %d %H:%M:%S %Y %z")
print(t)

# t = dt.datetime.utcnow()
t
t
t.replace(tzinfo=dt.timezone.utc)

t.replace(tzinfo=dt.timezone.utc).astimezone(tz=None)

utc_dt = dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)
utc_dt

utc_dt - t
utc_dt - t.replace(tzinfo=dt.timezone.utc)
utc_dt - t.replace(tzinfo=dt.timezone.utc).astimezone(tz=None)
from bdtime import tt


cls()
dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc) - tt.get_current_beijing_time_dt().replace(tzinfo=dt.timezone.utc)
tt.get_current_beijing_time_dt() - dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)


tt.get_current_beijing_time_dt().replace(tzinfo=dt.timezone.utc)
dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)

# 北京时间
current_beijing_time_dt = utc_now.astimezone(LOCAL_TIMEZONE)
dt.timezone(
    dt.timedelta(hours=0),
)


dt.datetime.utcnow().astimezone(tt.datetime_utils.LOCAL_TIMEZONE)
dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)
tt.get_current_beijing_time_dt()


utc_dt = dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)
utc_2 = dt.datetime.utcnow()


bj_now = tt.get_current_beijing_time_dt()
bj_2 = tt.get_current_beijing_time_dt()
bj_now.tzinfo
t.tzinfo
utc_dt.tzinfo == bj_now.tzinfo
utc_2.tzinfo == bj_now.tzinfo
bj_now.tzinfo == bj_2.tzinfo





86400 / 3600

dt.datetime.utcnow().replace(tzinfo=dt.timezone.utc)
tt.get_current_beijing_time_dt()


# 将下面的字符串时间转成"年-月-日 时:分:秒"的格式
t = "Thu Oct 14 10:31:21 +0000 2010"
# %a星期简写 %b月份简写 %d日期 %H小时 %M分钟 %S秒 %z时区 %Y年份
# 将字符串解析为时间元祖
t = time.strptime(t,"%a %b %d %H:%M:%S %z %Y")
print(t)
# 将时间元组格式化为指定的样式
t = time.strftime("%Y-%m-%d %H:%M:%S", t)
print(t)


